package com.chenjun.core.service.oa.impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.chenjun.common.model.DataGridModel;
import com.chenjun.core.dao.generator.entity.OaBillAttnMonthReportDtl;
import com.chenjun.core.dao.generator.mapper.OaBillAttnMonthReportDtlMapper;
import com.chenjun.core.dao.module.OaBillAttnMonthReportDtlRelationMapper;
import com.chenjun.core.service.oa.OaBillAttnMonthReportDtlService;

/**
 * @Description: 月结数据
 * @author dongyibin
 * @date 2017-9-3 下午2:35:30
 */
@Service
@Transactional
@SuppressWarnings("serial")
public class OaBillAttnMonthReportDtlServierImpl implements OaBillAttnMonthReportDtlService {
	
	@Autowired
	private OaBillAttnMonthReportDtlMapper OaBillAttnMonthReportDtlMapper;
	@Autowired
	private OaBillAttnMonthReportDtlRelationMapper monthReportDtlRelationMapper;
	
	@Override
	public OaBillAttnMonthReportDtl get(int id) {
		return OaBillAttnMonthReportDtlMapper.selectByPrimaryKey(id);
	}

	@Override
	public int create(OaBillAttnMonthReportDtl oaBillAttnMonthReportDtl) {
		return OaBillAttnMonthReportDtlMapper.insert(oaBillAttnMonthReportDtl);
	}

	@Override
	public int delete(int id) {
		return OaBillAttnMonthReportDtlMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int update(OaBillAttnMonthReportDtl oaBillAttnMonthReportDtl) {
		return OaBillAttnMonthReportDtlMapper.updateByPrimaryKeySelective(oaBillAttnMonthReportDtl);
	}

	@Override
	public int createOrUpdate(OaBillAttnMonthReportDtl oaBillAttnMonthReportDtl) {
		int rows = 0;
		if(StringUtils.isBlank(oaBillAttnMonthReportDtl.getId().toString())){
			rows = create(oaBillAttnMonthReportDtl);
		}else{
			rows = update(oaBillAttnMonthReportDtl);
		}
		return rows;
	}

	@Override
	public List<OaBillAttnMonthReportDtl> doListByCondition(DataGridModel param) {
		return monthReportDtlRelationMapper.selectByCondition(param);
	}

}
